package com.ltkj.ticket.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ltkj.ticket.domain.TicOtherBase;
import com.ltkj.ticket.domain.dto.TicScenicQueryDTO;
import com.ltkj.ticket.domain.dto.TicScenicStockAddDTO;
import com.ltkj.ticket.domain.dto.TicScenicUpdateDTO;
import com.ltkj.ticket.domain.vo.TicScenicPageVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ltkj.common.log.annotation.Log;
import com.ltkj.common.log.enums.BusinessType;
import com.ltkj.common.security.annotation.RequiresPermissions;
import com.ltkj.ticket.domain.TicScenicStock;
import com.ltkj.ticket.service.ITicScenicStockService;
import com.ltkj.common.core.web.controller.BaseController;
import com.ltkj.common.core.web.domain.AjaxResult;
import com.ltkj.common.core.utils.poi.ExcelUtil;
import com.ltkj.common.core.web.page.TableDataInfo;

/**
 * 景区门票库存Controller
 * 
 * @author ruoyi
 * @date 2023-08-31
 */
@Api(tags = "景区门票库存")
@RestController
@RequestMapping("/stock")
public class TicScenicStockController extends BaseController
{
    @Autowired
    private ITicScenicStockService ticScenicStockService;


    /**
     * 导出景区门票库存列表
     */
    @ApiOperation("导出景区门票库存列表")
    @RequiresPermissions("ticket:stock:export")
    @Log(title = "景区门票库存", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TicScenicStock ticScenicStock)
    {
        List<TicScenicStock> list = ticScenicStockService.selectTicScenicStockList(ticScenicStock);
        ExcelUtil<TicScenicStock> util = new ExcelUtil<TicScenicStock>(TicScenicStock.class);
        util.exportExcel(response, list, "景区门票库存数据");
    }

    /**
     * 新增景区门票库存
     */
    @ApiOperation("新增景区门票库存")
    @RequiresPermissions("ticket:stock:add")
    @Log(title = "景区门票库存", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TicScenicStockAddDTO addDTO)
    {
        return toAjax(ticScenicStockService.insertTicScenicStockNew(addDTO));
    }

    /**
     * 修改景区门票库存
     */
    @ApiOperation("修改景区门票库存")
    @RequiresPermissions("ticket:stock:edit")
    @Log(title = "景区门票库存", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody TicScenicUpdateDTO updateDTO)
    {
        return toAjax(ticScenicStockService.updateTicScenicStockNew(updateDTO));
    }

    /**
     * 删除景区门票库存
     */
    @ApiOperation("删除景区门票库存")
    @RequiresPermissions("ticket:stock:remove")
    @Log(title = "景区门票库存", businessType = BusinessType.DELETE)
    @DeleteMapping("/scenicStockIds")
    public AjaxResult remove(@PathVariable Long[] scenicStockIds)
    {
        return toAjax(ticScenicStockService.deleteTicScenicStockByScenicStockIds(scenicStockIds));
    }

    /**
     * 获取景区门票库存详细信息
     */
    @ApiOperation("获取景区门票库存详细信息")
    @RequiresPermissions("ticket:stock:query")
    @GetMapping(value = "/{scenicStockId}")
    public AjaxResult getInfo(@PathVariable("scenicStockId") Long scenicStockId)
    {
        return success(ticScenicStockService.selectTicScenicStockByScenicStockIdNew(scenicStockId));
    }

    /**
     * 获取景区门票库存详细信息
     */
    @ApiOperation("获取景区门票票种下拉")
    @RequiresPermissions("ticket:stock:select")
    @GetMapping
    public AjaxResult select()
    {
        return success(ticScenicStockService.selectType());
    }

    /**
     * 查询景区列表
     */
    @ApiOperation("查询景区库存列表")
    @RequiresPermissions("ticket:stock:list")
    @GetMapping("/list")
    public TableDataInfo list( TicScenicQueryDTO queryDTO)
    {
        startPage();
        List<TicScenicPageVo> list = ticScenicStockService.selectTicScenicList(queryDTO);
        return getDataTable(list);
    }
}
